﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Markup;
using System.Windows;

namespace XWord.WPF.ApplicationFramework.Markup
{
    public abstract class BaseMarkupExtension : MarkupExtension
    {
        protected IProvideValueTarget ProvideValueTarget { get; set; }

        protected FrameworkElement TargetObject { get; set; }

        protected DependencyProperty TargetProperty { get; set; }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(new FrameworkElement())) return null;
            ProvideValueTarget = serviceProvider as IProvideValueTarget;
            TargetObject = ProvideValueTarget.TargetObject as FrameworkElement;
            TargetProperty = ProvideValueTarget.TargetProperty as DependencyProperty;
            return ProvideValue();
        }
        public abstract object ProvideValue();
    }
}
